public class Main1447 {
    public static void main(String[] args) {
        for (int i=1000;i<10000;i++){
            int a=i/1000;//1
            int b=(i/100)%10;//6
            int c=(i%100)/10;//6
            int d=i%10;
            if (a==d&&b==c){
                System.out.println(i);
            }
        }
    }
}
